<%@page import="com.qmerak.entity.MemberEntity.Member_Status"%>
<%@page import="com.qmerak.common.ViewUtil"%>
<%@page import="com.qmerak.entity.MemberEntity"%>
<%@page import="com.qmerak.common.SysConstants"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css"
	href="../css/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="../css/themes/icon.css" />
<script type="text/javascript" src="../js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="../js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript">
	var objects = {};
	var cur_object = {};
	$(function() {
		buildTree();
	})
	function buildTree() {
		$.get("../view/tree", function(str) {
			if (typeof str != "undefined" && str instanceof Array) {
				$(str).each(function(i, node) {
					objects[node.id] = node;
					node.text = node.unionName;
					node.url = "function/org_info_manager.jsp";
					node.children = node.members;
					$(node.children).each(function(i, m) {
						objects[m.id] = m;
						m.text = m.name;
						m.url = "function/member_info_manager.jsp";
					});
				});
				var datas = [];
				$(str).each(function(i, node) {
					var parent = objects[node.parentid];
					if (typeof parent != "undefined") {
						parent.children.push(node);
					} else {
						datas.push(node);
					}
				});
				if (datas.length > 0) {
					showTree(datas);
				}
			}
		})
	}
	function openURL(url) {
		window.frames['mainpanel'].window.location = url;
	}

	function showTree(datas) {
		var te = $("#org_tree").empty();
		$(te).tree({
			lines : true,
			animate : false,
			onClick : function(node) {
				cur_object = objects[node.id];
				openURL(cur_object.url);
			}
		});
		$(te).tree('append', {
			parent : null,
			data : datas
		});
	}
</script>
</head>
<body id="layout" class="easyui-layout">
	<%
		MemberEntity user = (MemberEntity) request.getSession()
				.getAttribute(SysConstants.SYS_LOGIN_USER);
		boolean isZhuXi = ViewUtil.isZhuXi(user);
		boolean isFuZhuXi = ViewUtil.isFuZhuXi(user);
		boolean isLiShiZhang = ViewUtil.isLiShiZhang(user);
		boolean isGanBu = ViewUtil.isGanBu(user);
		boolean isHuiYuan = ViewUtil.isHuiYuan(user);
		boolean canApplySalvage = ViewUtil.canApplySalvage(user);
	%>
	<input name="loginUser" id="loginUser" type="hidden"
		value="<%=user.getName()%>" />
	<div style="height: 45px; width: 100%; overflow-y: hidden;"
		region="north">
		<iframe width="100%" height="100%" frameborder="0" scrolling="no"
			src="header.jsp"></iframe>
	</div>
	<div style="height: 100%; width: 220px; overflow-y: hidden;"
		split="true" region="west">
		<div id="myaccrdion" border="true" fit="true" class="easyui-accordion">
			<%
				if (isZhuXi || isFuZhuXi || isGanBu) {
			%>
			<div title="组织机构" icon="icon-sys">
				<div id="org_tree"></div>
			</div>
			<%
				}
			%>
			<div title="系统功能" icon="icon-sys">
				<%
					if (isZhuXi || isFuZhuXi || isLiShiZhang || isGanBu || isHuiYuan) {
				%>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('function/member_base_show.jsp')">基本信息</a></li>
				</ul>
				<%
					}
				%>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('function/modify_pwd.jsp')">密码修改</a></li>
				</ul>
				<%
					//理事长有权审批大病救助申请
					if (isLiShiZhang) {
				%>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('manager/salvage_approve_manage.jsp')">大病救助审批</a></li>
				</ul>
				<%
					}
				%>
				<%
					if (isGanBu) {

						if (canApplySalvage) {
				%>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('manager/salvage_apply_manage.jsp')">大病救助申请</a></li>
				</ul>
				<%
					}
				%>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('manager/approve_login.jsp')">入会审批</a></li>
				</ul>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('manager/approve_logoff.jsp')">退会审批</a></li>
				</ul>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('manager/approve_unionchange.jsp')">转会审批</a></li>
				</ul>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('function/member_logout.jsp')">注销会员</a></li>
				</ul>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('function/pwd_reset.jsp')">密码重置</a></li>
				</ul>
				<%
					}
					if (isHuiYuan) {
				%>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('manager/apply_ChangeUion.jsp')">转会申请</a></li>
				</ul>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('manager/apply_OutUion.jsp')">退会申请</a></li>
				</ul>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('manager/salvage_feedback_manage.jsp')">大病救助反馈</a></li>
				</ul>
				<%
					} else {
						if (user.getStatus().equals(Member_Status.NORMAL.name())) {
				%>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('manager/apply_IntoUion.jsp')">入会申请</a></li>
				</ul>
				<%
					}
					}
				%>
				<%
					if (isZhuXi || isFuZhuXi || isGanBu) {
				%>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('report/research_member.jsp')">会员查询</a></li>
				</ul>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('report/research_unit.jsp')">工作单位查询</a></li>
				</ul>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('report/research_union.jsp')">工会组织查询</a></li>
				</ul>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('report/report1.jsp')">统计报表</a></li>
				</ul>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('report/sexOfMemberChart.jsp')">会员男女比例统计图表</a></li>
				</ul>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('report/educationOfMemberChart.jsp')">会员受教育程度统计图表</a></li>
				</ul>
				<%
					}
				%>

			</div>
			<%
				if (isGanBu) {
			%>
			<div title="系统管理" icon="icon-sys">
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('function/edit_org.jsp')">工会组织管理</a></li>
				</ul>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('function/edit_unit.jsp')">工作机构管理</a></li>
				</ul>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('function/staff_import.jsp')">员工数据导入</a></li>
				</ul>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('function/edit_member.jsp')">会员管理</a></li>
				</ul>
				<ul>
					<li style="margin-top: 10px"><a
						href="javascript:openURL('function/member_roles.jsp')">角色设置</a></li>
				</ul>
				<!-- 				<ul> -->
				<!-- 					<li style="margin-top: 10px"><a -->
				<!-- 						href="javascript:openURL('function/edit_right.jsp')">权限管理</a></li> -->
				<!-- 				</ul> -->
			</div>
			<%
				}
			%>
		</div>
	</div>
	<div region="center" style="overflow-y: hidden;">
		<iframe id="mainpanel" name="mainpanel" width="100%" height="100%"
			frameborder="0" src="display.jsp"></iframe>
	</div>
	<div region="south"
		style="height: 25px; width: 100%; overflow-y: hidden; background: #BFDCEE;"></div>
</body>
</html>